# api/admin.py
from django.contrib import admin
from .models import (
    ReadingMaterial,
    SingleChoiceQuestion,
    MultipleChoiceQuestion,
    FillInBlankQuestion,
    Task,
    Experiment,
    StudentExperimentProgress,
    StudentAnswerRecord,
    Student,
    UserProfile,
    TeacherEvaluation,
    ExperimentAnnouncement,
    Teacher,
    StudentGroup,
    ExperimentReport,
    CodeQuestion,
    CodeSubmission
)
#注册学生小组
admin.site.register(StudentGroup)

#注册实验反馈报告

admin.site.register(ExperimentReport)
#注册实验公告
admin.site.register(ExperimentAnnouncement)

#注册教师评测模型
admin.site.register(TeacherEvaluation)
# 注册阅读材料
admin.site.register(ReadingMaterial)

# 注册题目类型
admin.site.register(SingleChoiceQuestion)
admin.site.register(MultipleChoiceQuestion)
admin.site.register(FillInBlankQuestion)

# 注册任务和实验
admin.site.register(Task)
admin.site.register(Experiment)

# 注册学生进度与答题记录
admin.site.register(StudentExperimentProgress)
admin.site.register(StudentAnswerRecord)

# 注册用户相关模型
admin.site.register(Student)
admin.site.register(Teacher)
admin.site.register(UserProfile)

#注册代码评测与提交模型
admin.site.register(CodeQuestion)
admin.site.register(CodeSubmission)
class ExperimentAdmin(admin.ModelAdmin):
    list_display = ('name', 'created_by', 'start_time', 'end_time', 'is_published')
    list_filter = ('is_published', 'created_by')
    search_fields = ('name', 'description')
    filter_horizontal = ('tasks', 'assigned_groups')

admin.site.unregister(Experiment)  # 先取消注册
admin.site.register(Experiment, ExperimentAdmin)  # 重新注册